<div class="toolbar">
  <form class="form-inline" action="<%= admin_events_path %>">
    <div class="form-group mr-sm-2">
      <input type="text" name="q" class="form-control" value="<%= params[:q] %>" placeholder="标题" />
</div>
<div class="form-group mr-sm-2">
  <input type="text" name="login" class="form-control" value="<%= params[:login] %>" placeholder="用户名" />
</div>
<button class="btn btn-default">搜索</button>
</form>


<table class="table table-bordered table-striped table-condensed">
  <tr class="head">
    <td class="first">#</td>
    <td style="width:300px">标题</td>
    <td>发帖人</td>
    <td>联系信息</td>
    <td>活动开始时间</td>
    <td>置顶时间</td>
    <td>status</td>
    <td style="width:100px"></td>
  </tr>
  <% @events.each do |event| %>
    <tr class="">
    <td class="first"><%= event.id %></td>
    <td>
      <%= link_to truncate(event.title, length: 30), event, target: "_blank" %>
    </td>
    <td><%= user_name_tag(event.user) %></td>
    <td>
      <dl><dt>姓名</dt><dd><%= event.realname%></dd></dl>
      <dl><dt>email</dt><dd><%= event.email%></dd></dl>
      <dl><dt>电话</dt><dd><%= event.phone%></dd></dl>
      <dl><dt>微信或qq</dt><dd><%= event.wechat_or_qq%></dd></dl>
    </td>

    <td>
      <%= event.start_at%>
    </td>

    <td>
      <%= event.suggested_at%>
    </td>
    <td>
      <%= event.status %>
    </td>
<td>
  <% if !event.suggested_at.blank? %>
    <%= link_to t("common.un_top"), unsuggest_admin_event_path(event), 'data-confirm' => 'Are you sure?', method: :post %>
  <% else %>
    <%= link_to t("common.place_top"), suggest_admin_event_path(event), 'data-confirm' => 'Are you sure?', method: :post %>
  <% end %>

  <% if event.status != 'success' %>
    <%= link_to "通过审核", publish_admin_event_path(event), 'data-confirm' => 'Are you sure?', method: :post %>
  <% else %>
    <%= link_to "驳回", failure_admin_event_path(event), 'data-confirm' => 'Are you sure?', method: :post %>
  <% end %>

  <%= link_to "", edit_event_path(event), class: "fa fa-edit" %>
  <%= link_to "", admin_event_path(event), 'data-confirm' => 'Are you sure?', method: :delete, class: "fa fa-trash" %>
</td>
</tr>
<% end %>
</table>
<%= paginate @events %>